//package com.example.waibao.controller;
//
//
//import com.example.waibao.config.scheduled.ITask;
//import com.example.waibao.config.scheduled.ScheduledTaskRegistrar;
//import com.example.waibao.service.UserService;
//import com.example.waibao.service.impl.ScheduledService;
//import com.example.waibao.service.taskService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.support.CronTrigger;
//import org.springframework.scheduling.support.SimpleTriggerContext;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.io.IOException;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//import java.util.stream.Collectors;
//
//@RestController
//@RequestMapping("/task")
//public class ScheduledController {
//
//    @Autowired
//    private ScheduledTaskRegistrar scheduledTaskRegistrar;
//
//
//
//    @Autowired
//    private UserService userService;
//
//    @Autowired
//    private com.example.waibao.service.taskService taskService;
//
//
//    @Autowired
//    ScheduledService scheduledService;
//
//    @PostMapping("ttt")
//    public void ttt() throws IOException {
//
//        scheduledService.scheduled();
////        int school_id = userService.get_a_school_id(1);
////        List<String> boxs = taskService.get_box(school_id);
////        System.out.println(school_id);
////        System.out.println(boxs);
//    }
//
//
//
//    @GetMapping
//    public List<Map<String,Object>> listTask(){
//        return scheduledTaskRegistrar.list().stream().map(e->{
//            Map<String,Object> temp = new HashMap<>();
//            ITask task = e.getTask();
//            temp.put("任务名",task.getTaskName());
//            temp.put("任务描述",task.getTaskDescription());
//            temp.put("cron表达式",task.getCron());
//            temp.put("任务状态",e.terminate()?"已停止":"运行中");
//            temp.put("任务类名",task.getClass().getName());
//            temp.put("下次执行时间",new CronTrigger(task.getCron()).nextExecutionTime(new SimpleTriggerContext()));
//            return temp;
//        }).collect(Collectors.toList());
//    }
//
//
//
//    @PostMapping("/pause")
//    public void pause(String class_name){
//        scheduledTaskRegistrar.pause(class_name);
//    }
//
//
//    @PostMapping("/start")
//    public void start(String class_name){
//        scheduledTaskRegistrar.start(class_name);
//    }
//
//    @PostMapping("/restart")
//    public void restart(String class_name,String cron){
//        scheduledTaskRegistrar.restart(class_name,cron);
//    }
//
//}
